home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Unix / satan-1.1.1 / bin / nfs-chk.satan < prev    next >
Text File  |  1996-04-24  |  2KB  |  66 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # Report file systems that are exported via portmap or that can be mounted
  4. # by unpriviliged programs. World-mountable file systems are already taken
  5. # care of by showmount.satan.
  6. #
  7. # version 1, Mon Mar 20 18:48:11 1995, last mod by wietse
  8. #
  9.  
  10. $running_under_satan = 1;
  11. require 'config/satan.cf';
  12. require 'config/paths.pl';
  13. require 'perl/misc.pl';
  14. require 'perl/hostname.pl';
  15. require 'perl/getfqdn.pl';
  16. require 'perllib/getopts.pl';
  17.  
  18. $usage="Usage: $0 [-t timeout -u -v] target";
  19. $opt_u = $untrusted_host;
  20. &Getopts("t:uv") || die $usage;
  21. $timeout = $short_timeout;
  22.  
  23. ($#ARGV == 0) || die $usage;
  24.  
  25. $target = $ARGV[0];
  26. $flags = "-v" if defined($opt_v);
  27. $timeout = $opt_t if defined($opt_t);
  28. $untrusted_host = $opt_u;
  29.  
  30. $flags = "$flags -t $timeout" if defined($opt_t);
  31.  
  32. $service = &basename($0, ".satan");
  33. $severity = "x";
  34. $status = "a";
  35. $service_output = "";
  36.  
  37. $| = 1;
  38.  
  39. open(NFS, "$NFS_CHK $flags $target |") || die "$0: cannot run nfs-chk";
  40. while(<NFS>) {
  41.     if (defined($opt_v)) {
  42.         print;
  43.     }
  44.     if (/exports (\S+) via portmapper/) {
  45.         $trusted = "ANY\@ANY";
  46.         $trustee = "$1\@$target";
  47.         $service_output = "NFS export via portmapper";
  48.         $text = "exports $1 via portmapper";
  49.         &satan_print();
  50.     } elsif ($untrusted_host && /Mounted: (\S+) via mount daemon/) {
  51.         $trusted = "ANY\@ANY";
  52.         $trustee = "$1\@$target";
  53.         $service_output = "unrestricted NFS export";
  54.         $text = "exports $1 to everyone";
  55.         &satan_print();
  56.     } elsif (/exports (\S+) to unprivileged/) {
  57.         $this_host = &getfqdn(&hostname());
  58.         $trusted = "ANY\@$this_host";
  59.         $trustee = "$1\@$target";
  60.         $service_output = "NFS export to unprivileged programs";
  61.         $text = "exports $1 to unprivileged programs";
  62.         &satan_print();
  63.     }
  64.     # world-wide exports already taken care of in showmount.satan
  65. }
  66.